<!DOCTYPE html>
<html>
<head>
<title>RC Circuit Diagram</title>
</head>
<body>

<canvas id="rcCircuitCanvas" width="350" height="250" style="border:1px solid #d3d3d3;"></canvas>

<script>
    const canvas = document.getElementById('rcCircuitCanvas');
    const ctx = canvas.getContext('2d');

    // Style settings
    ctx.lineWidth = 2;
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.font = '20px serif';
    
    // --- Define component coordinates ---
    const leftX = 50;
    const rightX = 300;
    const topY = 50;
    const bottomY = 200;
    
    // --- Draw Wires ---
    ctx.beginPath();
    // Top wire
    ctx.moveTo(leftX, topY);
    ctx.lineTo(100, topY); // to switch
    ctx.moveTo(150, topY); // from switch
    ctx.lineTo(190, topY); // to capacitor
    ctx.moveTo(220, topY); // from capacitor
    ctx.lineTo(rightX, topY);
    // Right wire
    ctx.moveTo(rightX, topY);
    ctx.lineTo(rightX, bottomY);
    // Bottom wire
    ctx.moveTo(rightX, bottomY);
    ctx.lineTo(250, bottomY); // to resistor
    ctx.moveTo(150, bottomY); // from resistor
    ctx.lineTo(leftX, bottomY);
    // Left wire
    ctx.moveTo(leftX, bottomY);
    ctx.lineTo(leftX, 130); // to battery
    ctx.moveTo(leftX, 110); // from battery
    ctx.lineTo(leftX, topY);
    ctx.stroke();

    // --- Draw Battery (EMF source ξ) ---
    ctx.beginPath();
    // Positive terminal (longer line)
    ctx.moveTo(leftX - 20, 110);
    ctx.lineTo(leftX + 20, 110);
    // Negative terminal (shorter line)
    ctx.moveTo(leftX - 10, 130);
    ctx.lineTo(leftX + 10, 130);
    ctx.stroke();
    // Label
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    ctx.fillText('ξ', leftX - 30, 120);

    // --- Draw Switch (S) ---
    ctx.beginPath();
    // Switch arm (open)
    ctx.moveTo(100, topY);
    ctx.lineTo(150, topY - 15);
    ctx.stroke();
    // Contact points
    ctx.beginPath();
    ctx.arc(100, topY, 3, 0, 2 * Math.PI);
    ctx.fill();
    ctx.beginPath();
    ctx.arc(150, topY, 3, 0, 2 * Math.PI);
    ctx.fill();
    // Label
    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';
    ctx.fillText('S', 125, topY - 15);

    // --- Draw Capacitor (C) ---
    ctx.beginPath();
    // Plates
    ctx.moveTo(190, topY - 20);
    ctx.lineTo(190, topY + 20);
    ctx.moveTo(220, topY - 20);
    ctx.lineTo(220, topY + 20);
    ctx.stroke();
    // Label
    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';
    ctx.fillText('C', 205, topY - 20);

    // --- Draw Resistor (R) ---
    ctx.beginPath();
    // Zigzag line
    ctx.moveTo(150, bottomY);
    ctx.lineTo(162.5, bottomY - 10);
    ctx.lineTo(187.5, bottomY + 10);
    ctx.lineTo(212.5, bottomY - 10);
    ctx.lineTo(237.5, bottomY + 10);
    ctx.lineTo(250, bottomY);
    ctx.stroke();
    // Label
    ctx.font = '20px sans-serif';
    ctx.textAlign = 'center';
    ctx.textBaseline = 'bottom';
    ctx.fillText('R', 200, bottomY - 15);

</script>

</body>
</html>